/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.games.base;

import java.util.Collection;

import org.ceroproject.games.Action;
import org.ceroproject.games.ActionEvent;
import org.ceroproject.games.ActionException;
import org.ceroproject.games.ActionRule;
import org.ceroproject.games.Card;
import org.ceroproject.games.Game;
import org.ceroproject.games.Player;
import org.ceroproject.games.StopCondition;
import org.ceroproject.games.ValidationException;
import org.ceroproject.games.Zone;


/**
 * This class, when added as a stopCondition and registered as an action to the
 * game, will approve itself, then stop the game.
 * 
 * @author Telem
 */
class GameStopper implements StopCondition, Action, ActionRule {
	private ActionEvent event;

	public boolean shouldStop(Game game) {
		return true;
	}

	public String getRuleName() {
		return "Stop the Game";
	}

	public String getRuleDescription() {
		return "This stops the game as soon as possible";
	}

	public String getRuleConstraints() {
		return null;
	}

	public void validateGame(Game game) throws ValidationException {

	}

	public String getActionName() {
		return "Stop the game";
	}

	public void executeAction() {

	}

	public void playerActed(ActionEvent event) throws ActionException {
		this.event = event;
	}

	public ActionEvent getEvent() {
		return event;
	}

	public boolean allowsAction(Action action) {
		return true;
	}

	public boolean forbidsAction(Action action) {
		return false;
	}

	public Class ruledAction() {
		return GameStopper.class;
	}

	public boolean canAct(ActionEvent event) {
		return true;
	}

	public void initializeRule(Game game) {
	}

	public Player getPlayer() {
		return event.getPlayer();
	}

	public Game getGame() {
		return event.getGame();
	}

	public Zone getZoneFrom() {
		return event.getZoneFrom();
	}

	public Zone getZoneTo() {
		return event.getZoneTo();
	}

	public Collection<Card> getCards() {
		return event.getCards();
	}

}
